package com.duan.service;

import com.duan.mapper.RecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordService {
    private final RecordMapper recordMapper;

    @Autowired
    public RecordService(RecordMapper recordMapper){
        this.recordMapper = recordMapper;
    }

    //增加奖项awardId对应的中奖人员memberId的记录
    public int add(List<Integer> memberIds, Integer awardId){
        return recordMapper.batchInsert(memberIds, awardId);
    }

    //通过awardId删除抽奖记录
    public int deleteByAwardId(Integer id){
        return recordMapper.deleteByAwardId(id);
    }

    //通过memberId删除抽奖记录
    public int deleteByMemberId(Integer id){ return recordMapper.deleteByMemberId(id); }

    //删除所有的抽奖记录
    public int deleteByUserId(Integer id){
        return recordMapper.deleteByUserId(id);
    }


}
